#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int maxp = 100+2, maxn = 50+5;
bool G[maxp][maxp][maxp];
vector<int> x, y, z;
map<int, int> xid, yid, zid;
int XN, YN, ZN, N;
int x1[maxn], x2[maxn], y1[maxn], y2[maxn], z1[maxn], z2[maxn];

void init(){
    memset(G, false, sizeof(G));
    x.push_back(0);
    y.push_back(0);
    z.push_back(0);
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    int T; cin >> T;
    while(T--){
        init();
        cin >> N;
        for (int i = 1; i <= N; ++i) {
            cin >> x1[i] >> y1[i] >> z1[i] >> x2[i] >> y2[i] >> z2[i];
            x.push_back(x1[i]); x.push_back(x2[i]);
            y.push_back(y1[i]); y.push_back(y2[i]);
            z.push_back(z1[i]); z.push_back(z2[i]);
        }
        XN = unique(x.begin(), x.end()) - x.begin();
        YN = unique(y.begin(), y.end()) - y.begin();
        ZN = unique(z.begin(), z.end()) - z.begin();

        for (int i=0; i<XN; ++i) xid[x[i]] = i;
        for (int i=0; i<YN; ++i) yid[y[i]] = i;
        for (int i=0; i<ZN; ++i) zid[z[i]] = i;

        for (int i = 0; i < N; ++i) {
            int xl = xid[x1[i]], xr = xid[x2[i]];
            int yl = yid[y1[i]], yr = yid[y2[i]];
            int zl = zid[z1[i]], zr = zid[z2[i]];

            for (int xx = xl; xx < xr; ++xx) {
                for (int yy = yl; yy < yr; ++yy) {
                    for (int zz = zl; zz < zr; ++zz) {
                        G[xx][yy][zz] = true;
                    }
                }
            }
        }

    }
    return 0;
}